uniform sampler2D firstDepthShadowMap; 
uniform sampler2D secondDepthShadowMap; 
uniform float offset;
uniform float textureSize;

           
void main(void){

  float firstDepth= texture2D(firstDepthShadowMap, gl_TexCoord[0].st).r;

  float secondDepth= texture2D(secondDepthShadowMap, gl_TexCoord[0].st).r;
  
  gl_FragColor= vec4(1.0);
  gl_FragDepth= firstDepth + min(offset, (secondDepth-firstDepth)/2.0);
  
  //gl_FragDepth= firstDepth;
}
